/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.ClassNumber;
import de.thwildau.tm.moses.asn1.asn1.Tag;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Tag</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.TagImpl#getEncodingReference <em>Encoding Reference</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.TagImpl#getTagClass <em>Tag Class</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.TagImpl#getClassNumber <em>Class Number</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TagImpl extends MinimalEObjectImpl.Container implements Tag
{
  /**
   * The default value of the '{@link #getEncodingReference() <em>Encoding Reference</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEncodingReference()
   * @generated
   * @ordered
   */
  protected static final String ENCODING_REFERENCE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getEncodingReference() <em>Encoding Reference</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEncodingReference()
   * @generated
   * @ordered
   */
  protected String encodingReference = ENCODING_REFERENCE_EDEFAULT;

  /**
   * The default value of the '{@link #getTagClass() <em>Tag Class</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTagClass()
   * @generated
   * @ordered
   */
  protected static final String TAG_CLASS_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getTagClass() <em>Tag Class</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTagClass()
   * @generated
   * @ordered
   */
  protected String tagClass = TAG_CLASS_EDEFAULT;

  /**
   * The cached value of the '{@link #getClassNumber() <em>Class Number</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getClassNumber()
   * @generated
   * @ordered
   */
  protected ClassNumber classNumber;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected TagImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.TAG;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getEncodingReference()
  {
    return encodingReference;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEncodingReference(String newEncodingReference)
  {
    String oldEncodingReference = encodingReference;
    encodingReference = newEncodingReference;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.TAG__ENCODING_REFERENCE, oldEncodingReference, encodingReference));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getTagClass()
  {
    return tagClass;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTagClass(String newTagClass)
  {
    String oldTagClass = tagClass;
    tagClass = newTagClass;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.TAG__TAG_CLASS, oldTagClass, tagClass));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ClassNumber getClassNumber()
  {
    return classNumber;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetClassNumber(ClassNumber newClassNumber, NotificationChain msgs)
  {
    ClassNumber oldClassNumber = classNumber;
    classNumber = newClassNumber;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.TAG__CLASS_NUMBER, oldClassNumber, newClassNumber);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setClassNumber(ClassNumber newClassNumber)
  {
    if (newClassNumber != classNumber)
    {
      NotificationChain msgs = null;
      if (classNumber != null)
        msgs = ((InternalEObject)classNumber).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.TAG__CLASS_NUMBER, null, msgs);
      if (newClassNumber != null)
        msgs = ((InternalEObject)newClassNumber).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.TAG__CLASS_NUMBER, null, msgs);
      msgs = basicSetClassNumber(newClassNumber, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.TAG__CLASS_NUMBER, newClassNumber, newClassNumber));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.TAG__CLASS_NUMBER:
        return basicSetClassNumber(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.TAG__ENCODING_REFERENCE:
        return getEncodingReference();
      case Asn1Package.TAG__TAG_CLASS:
        return getTagClass();
      case Asn1Package.TAG__CLASS_NUMBER:
        return getClassNumber();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.TAG__ENCODING_REFERENCE:
        setEncodingReference((String)newValue);
        return;
      case Asn1Package.TAG__TAG_CLASS:
        setTagClass((String)newValue);
        return;
      case Asn1Package.TAG__CLASS_NUMBER:
        setClassNumber((ClassNumber)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.TAG__ENCODING_REFERENCE:
        setEncodingReference(ENCODING_REFERENCE_EDEFAULT);
        return;
      case Asn1Package.TAG__TAG_CLASS:
        setTagClass(TAG_CLASS_EDEFAULT);
        return;
      case Asn1Package.TAG__CLASS_NUMBER:
        setClassNumber((ClassNumber)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.TAG__ENCODING_REFERENCE:
        return ENCODING_REFERENCE_EDEFAULT == null ? encodingReference != null : !ENCODING_REFERENCE_EDEFAULT.equals(encodingReference);
      case Asn1Package.TAG__TAG_CLASS:
        return TAG_CLASS_EDEFAULT == null ? tagClass != null : !TAG_CLASS_EDEFAULT.equals(tagClass);
      case Asn1Package.TAG__CLASS_NUMBER:
        return classNumber != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (encodingReference: ");
    result.append(encodingReference);
    result.append(", tagClass: ");
    result.append(tagClass);
    result.append(')');
    return result.toString();
  }

} //TagImpl
